package com.zlsy.thread.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author zhouliang
 * @date 2020/7/1 20:36
 * <p>
 * 周期性执行的线程池:第一种用法演示（线程池启动之后）
 */
public class NewScheduledThreadPoolTest1 {

    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
        /**
         * 第一种用法线程池启动后3秒执行任务
         */
        scheduledExecutorService.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
            }
        }, 3, TimeUnit.SECONDS);

    }
}
